<?php
include "../include/lib_func.php";
	
	$jml = $_POST['jumlah'];
	$id  = $_POST['id_produk'];
	$id_pesanan = $_POST['id_pesanan'];
	
	$jml_data = count($jml);
	
	$kon = koneksi_db();
	
	for ($i=0; $i<$jml_data; $i++) {
		if ($jml[$i]=='0' or ctype_digit($jml[$i])==false or $jml[$i]=='') {
			echo "<script language='javascript'>alert('Kesalahan dalam memasukan jumlah item !')</script>";
			echo "<script language='javascript'>window.location = '../view_keranjang.php'</script>";
		}
	}
	
	for ($i=0; $i<$jml_data; $i++) {
		mysql_query("update pesanan_item set qty='$jml[$i]' where id_produk='$id[$i]' and id_pesanan='$id_pesanan'",$kon);
	}
	
	echo "<script language='javascript'>window.location = '../view_keranjang.php'</script>";
	
?>